package com.community.mapper.room;


import com.community.entity.ContactRoom;
import com.community.entity.Room;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoomMapper {

    @Insert("insert into community.room(id, point, building, room, gender, name, mobile, userId) VALUES (#{id}, #{point}, #{building},#{room}, #{gender}, #{name}, #{mobile}, #{userId})")
    void add(@Param("id") String id,@Param("point") String point,@Param("building") String building,@Param("name") String name,@Param("room") String room,  @Param("gender") String gender,@Param("mobile") String mobile, @Param("userId")String userId);


    @Update("update community.room set point = #{point}, building = #{building}, name = #{name}, room = #{room}, gender = #{gender}, mobile = #{mobile} where id = #{id}" )
    void edit(@Param("id") String id,@Param("point") String point,@Param("building") String building, @Param("name") String name,@Param("room") String room, @Param("gender") String gender,@Param("mobile") String mobile);


    @Update("update community.room set status = #{status} where id = #{id}")
    void modifyStatus(@Param("id") String id,@Param("status") Integer status);


    @Select("select id, point, building, room, name, gender, status from community.room where userId = #{userId}")
    List<Room> getRoomInfo(@Param("userId") String userId);


    @Update("update room set isDelete = 1 where id = #{id}")
    void deleteRoom(@Param("id") String id);


    @Select("select id, point, building, room, name, gender, mobile, status from room where id = #{id}")
    Room getRoomDetail(@Param("id") String id);


    @Select("select id, CONCAT(point, building, room) AS name from room where userId = #{userId} and status = 2")
    List<ContactRoom> getStatusInfo(@Param("userId") String userId);

    @Select("select CONCAT(point, building, room) as name from  room where id = #{id}")
    ContactRoom getRoomName(@Param("id") String id);
}
